from tools.treeNode import Tree


def isSameTree(p, q):
    if not p and not q:
        return True
    elif not p or not q:
        return False
    elif p.val != q.val:
        return False
    else:
        return isSameTree(p.left, q.left) and isSameTree(p.right, q.right)


p = Tree(1)
p.left = Tree(2)

q = Tree(1)
q.left = Tree(2)
print(isSameTree(p, q))
